import webapp2
import logging

def handle_404(request, response, exception):
    logging.exception(exception)
    response.write('Oops! I could swear this page was here!')
    response.set_status(404)

def handle_500(request, response, exception):
    logging.exception(exception)
    response.write('A server error occurred!')
    response.set_status(500)

application = webapp2.WSGIApplication([
    webapp2.Route(r'/', handler='webapp.index.IndexPage'),
    webapp2.Route(r'/button', handler='webapp.button.ButtonPage', handler_method='get'),
    webapp2.Route(r'/buttons.json', handler='webapp.button.ButtonPage', handler_method='sample_json_object'),
])

application.error_handlers[404] = handle_404
application.error_handlers[500] = handle_500
